package com.laicunba.service.impl;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;

import com.laicunba.event.TestEvent;
import com.laicunba.pojo.BaseDO;
import com.laicunba.pojo.TestDO;
import com.laicunba.pojo.UserDO;
import com.laicunba.service.TestService;
import com.laicunba.util.AssertUtil;

@Service
public class TestServiceImpl extends BaseServiceImpl implements TestService, ApplicationEventPublisherAware {
	private ApplicationEventPublisher applicationEventPublisher;

	@Override
	public boolean create(BaseDO entiry) {
		AssertUtil.assertTrue(super.create(entiry));
		TestDO testDO = (TestDO) entiry;
		TestEvent event = new TestEvent(testDO);
		try {
			applicationEventPublisher.publishEvent(event);

		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	}

	@Override
	public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
		this.applicationEventPublisher = applicationEventPublisher;

	}

}
